<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>班级博客-登陆页</title>
    <link rel="stylesheet" href="./css/register/login.css">
    <link rel="shortcut icon" href="./img/blog-sy/favicon.ico" type="image/x-icon">
</head>

<body>
    <h1 class="title">班级博客-登陆页</h1>
    <div>
        <form id="login" class="current1" method="post">
            <h3>用户登入</h3>
            <img class="avator" src="./img/register/images (1).png" width="96" height="96" />
            <label>邮箱/名称<input type="text" name="userName" style="width:215px;" /><span>邮箱为空</span></label>
            <label>密码<input type="password" name="pass" /><span>密码为空</span></label>
            <button type="button" class="loginBtn ">登入</button>
            <a href="./zc"><button type="button">注册</button></a>
            <a href='/'style='cursor: pointer;'>返回主页</a>
        </form>

    </div>
</body>
<script src="./lib/jquery-3.3.1.js"></script>
<script src="./js/register/login.js"></script>
<script>
    // 登陆页面的 校验
    $('.loginBtn').on('click', function () {
        var formData = $('form').serialize();
        $.ajax({
            type: 'get',
            url: '/loginUser',
            data: formData ,
            success: function (data) {
                console.log(data.userdata)
                if(data.code=='1001'){
                    location.href='/';
                    alert(data.msg);
                }
                if(data.code=='1002'){
                    alert(data.msg);
                    location.href='/login';
                }
            }
        })
    })
</script>

</html>